from django.http import JsonResponse
from django.views import View
from housecentapp.models import Stoges, Houses


class Stogeapis(View):
    def get(self,request,*args,**kwargs):
        stoge = Stoges.objects.get(id=kwargs["stogeid"])
        houses = Houses.objects.filter(stoge_id=kwargs["stogeid"])
        print(houses)
        data=[]
        for house in houses:
            data.append({
                "id":house.id,
                "name":house.name
            })
        return JsonResponse({"stoge":stoge.name,"house":data})
    def post(self):
        pass
    def put(self):
        pass
    def petch(self):
        pass
    def delete(self):
        pass